
default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  lane :custom_lane do
    # add actions here: https://docs.fastlane.tools/actions
  end
  
  #  lane :beta do
  #  build_app(scheme: "myg_fastlane01")
  #  end
  notification(app_icon:"./fastlane/icon.png",title:"oc_fastlane",subtitle: "开始编译>>>>>>>>", message: "正在编译....")
  lane :buildApp do
      build_app(
      workspace: "myg_fastlane01.xcworkspace",
      configuration: "Debug",
      scheme: "myg_fastlane01",
      silent: true,
      clean: true,
      output_directory: "./fastlane/package", # Destination directory. Defaults to current directory.
      output_name: "myg_fastlane01.ipa"       # specify the name of the .ipa file to generate (including file extension)
    )
    notification(app_icon:"./fastlane/icon.png",title:"oc_fastlane",subtitle: "编译完成>>>>>>>>", message: "编译完成....")

    notification(app_icon:"./fastlane/icon.png",title:"oc_fastlane",subtitle: "上传到蒲公英>>>>>>>>", message: "正在上传....")

    pgyer(api_key: "4859dd76e4ab47ee892c13f32c68bbfb", user_key: "0751a5ab718354ea38b418e8a49b55f0")
     
    notification(app_icon:"./fastlane/icon.png",title:"oc_fastlane",subtitle: "上传完成>>>>>>>>", message: "上传完成...")

    
  end
  
  lane :test_flight_upload do
          api_key = app_store_connect_api_key(
                key_id: "W8R2RQRL45",
                issuer_id: "ffa427b7-d74d-4a21-8993-8f0477176e7d",
                key_filepath: "./fastlane/AuthKey_W8R2RQRL45.p8",
                duration: 1200, # optional (maximum 1200)
                in_house: false # optional but may be required if using match/sigh
          )
          upload_to_testflight(
              api_key: api_key,
              skip_waiting_for_build_processing: true,
              # username: "1xxxx@163.com",
              # app_identifier: "com.sxx.xxx",
              ipa: "./fastlane/package/myg_fastlane01.ipa",
              skip_submission:true
         )
 end
 
 lane :app_store_upload do
          api_key = app_store_connect_api_key(
                key_id: "W8R2RQRL45",
                issuer_id: "ffa427b7-d74d-4a21-8993-8f0477176e7d",
                key_filepath: "./fastlane/AuthKey_W8R2RQRL45.p8",
                duration: 1200, # optional (maximum 1200)
                in_house: false # optional but may be required if using match/sigh
          )
         upload_to_app_store(
              api_key:api_key,
              force: true, # Set to true to skip verification of HTML preview
              ipa: "./fastlane/package/myg_fastlane01.ipa",
         )
 end
  

  lane :certi do
    sync_code_signing(type: "development",app_identifier: "com.xyg.fastlane",
            git_url: "git@gitee.com:xiyg/app_test_cer.git")
  end

  lane :build do
    increment_build_number
    build_app(scheme: "myg_fastlane01",
            workspace: "myg_fastlane01.xcworkspace",
            include_bitcode: true)
  end
  
  
    desc "build app project"
    lane :build_app do
    cocoapods
    match
    increment_build_number
    gym(scheme: "myg_fastlane01",
            workspace: "myg_fastlane01.xcworkspace",
            include_bitcode: true)
    end
    
    desc "build app project to test"
    lane :build_test do
        cocoapods
        match
        increment_build_number
        scan
    end
    
    desc "upload to pgy"
    lane :build_app_pgy do
        cocoapods
        match
        increment_build_number
        gym(scheme: "myg_fastlane01",
                workspace: "myg_fastlane01.xcworkspace",
                include_bitcode: true)
        pgyer(api_key: "4859dd76e4ab47ee892c13f32c68bbfb", user_key: "0751a5ab718354ea38b418e8a49b55f0")
    end
  
    desc "upload to testflight"
    lane :build_app_to_testflight do
        cocoapods
        match
        increment_build_number
        gym(scheme: "myg_fastlane01",
                workspace: "myg_fastlane01.xcworkspace",
                include_bitcode: true)
        pilot
    end
  
    desc "upload to appstore"
    lane :build_app_to_appstore do
        cocoapods
        match
        increment_build_number
        gym(scheme: "myg_fastlane01",
                workspace: "myg_fastlane01.xcworkspace",
                include_bitcode: true)
        deliver(force: true)
    end
  
end
